package com.example.educationplatformbackend.controller;


import com.example.educationplatformbackend.domian.home.Course;
import com.example.educationplatformbackend.service.Impl.CourseService;
import com.example.educationplatformbackend.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseController {


    @Autowired
    CourseService courseService;

    @GetMapping("course")
    public ResponseResult<List<Course>> course(){
        return ResponseResult.success(courseService.course());
    }



    @PostMapping("addcourse")
    public  ResponseResult<Object> addcourse(@RequestBody Course course){
        courseService.addcourse(course);
        return ResponseResult.success("成功");
    }


    @GetMapping("deletecourse/{id}")
    public ResponseResult<Object> deleteCourseById(@PathVariable int id) {
        courseService.deleteCourseById(id);
        return ResponseResult.success("成功");
    }


    @PostMapping("updatecourse")
    public ResponseResult<Object> updateCourseById(@RequestBody Course course) {
        courseService.updateCourseById(course);
        return ResponseResult.success("成功");
    }

}
